package 斗地主;

import java.util.*;
public class makebrank {                     //制造牌
	
	public List<brank> c = new ArrayList<>();  //c为牌库
	
	public makebrank() {	
		String[] number = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
		String[] color = {"♣","♥", "♠", "◇"};
		int size = 2; 
	
		for(String o : number) {
			size++;
			for(String e : color ) {
				//System.out.printf("%s%s      ",e,o);
				brank b = new brank(e,o,size); //b为实列化的一个对象
				c.add(b); //将对象放入牌库中
				
			}
			//System.out.println();
			
		}
		brank xiaowang =new brank("", "小王",++size);
		brank dawang= new brank("", "大王",++size);
		c.add(dawang);
		c.add(xiaowang);
		System.out.println("----------------牌库信息----------------");
	    System.out.println("原始的牌"+c);
		Collections.shuffle(c);//洗牌————将集合中的牌打乱
		System.out.println("洗好的牌"+c);
		System.err.println("---------------------------------------");
		
		                     
		List<brank> player1 = new ArrayList<>();		
		List<brank> player2 = new ArrayList<>();	
		List<brank> player3 = new ArrayList<>(); //创建3个玩家
		
		for(int i = 0;i < c.size() - 3;i++) {//发牌
			if(i%3==0) {player1.add(c.get(i));}
			if(i%3==1) {player2.add(c.get(i));}
			if(i%3==2) {player3.add(c.get(i));}
		}
		
		System.out.println("玩家一的牌："+player1);
		System.out.println("玩家二的牌："+player2);
		System.out.println("玩家三的牌："+player3);
		
		System.err.println("---------------------------------------");
		
		              //排序
		//Collections.sort(List<brank> player1);
		//Collections.sort(player1,c);
		//Collections.sort(List<brank> player1, Comparator<brank>());
		
		
		
	}
					
}
